package com.mjk.manager.magicapi.plugin.webservice;

import com.mjk.manager.magicapi.core.core.config.MagicConfiguration;
import com.mjk.manager.magicapi.core.core.config.MagicPluginConfiguration;
import com.mjk.manager.magicapi.core.core.model.Plugin;
import com.mjk.manager.magicapi.core.core.web.MagicControllerRegister;
import com.mjk.manager.magicapi.plugin.webservice.resource.WebServiceMagicDynamicRegistry;
import com.mjk.manager.magicapi.plugin.webservice.resource.WebServiceMagicResourceStorage;
import com.mjk.manager.magicapi.plugin.webservice.web.MagicWebServiceController;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * webseravice 插件配置配
 */
@Configuration
public class MagicAPIWebServiceConfiguration implements MagicPluginConfiguration {
    /**
     * 注册资源类型
     *
     * @return
     */
    @Bean
    @ConditionalOnMissingBean
    public WebServiceMagicResourceStorage webserviceMagicResourceStorage() {
        return new WebServiceMagicResourceStorage();
    }

    @Bean
    @ConditionalOnMissingBean
    public WebServiceMagicDynamicRegistry webServiceMagicDynamicRegistry(WebServiceMagicResourceStorage taskInfoMagicResourceStorage) {

        return new WebServiceMagicDynamicRegistry(taskInfoMagicResourceStorage);
    }

//    @Override
//    public MagicControllerRegister controllerRegister() {
//        return (mapping, configuration) -> mapping.registerController(new MagicWebServiceController(configuration));
//    }

    @Override
    public Plugin plugin() {
        return new Plugin("WebService服务", "MagicWebService", "magic-webservice.1.0.0.iife.js");
    }
}
